package com.hzdracom.epubreader.activity;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.hzdracom.epubreader.views.image.TouchImageView;
import com.shwread.android.qysw10000182.R;

/**
 * 阅读器图片查看
 */
public class PictureActivity extends Activity {
    public static final String PATH_KEY = "path";
    public static final String COLOR_KEY = "color";

    private RelativeLayout layout;
    private TouchImageView tiv;
    private ImageView ivBack;

    private String path;
    private int color;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.epub3_activity_picture);

        tiv = (TouchImageView) findViewById(R.id.activity_picture_tiv);
        ivBack = (ImageView) findViewById(R.id.activity_picture_back);
        layout = (RelativeLayout) findViewById(R.id.activity_picture_layout);
        if (getIntent().hasExtra(PATH_KEY)) {
            path = getIntent().getStringExtra(PATH_KEY);
            tiv.setImageURI(Uri.parse(path));
        }
        if (getIntent().hasExtra(COLOR_KEY)) {
            color = getIntent().getIntExtra(COLOR_KEY, 0);
            if (color != 0) {
                layout.setBackgroundColor(color);
            }
        }

        ivBack.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

}
